import QtQuick

Item {
    id: bracketParameterBack_ParameterWindow
    width: 1760
    height: 935

    property real fontSize: Cpp_Language.CurrentLanguage === 1 ? 40 : Cpp_Language.CurrentLanguage === 2 ? 25 : Cpp_Language.CurrentLanguage === 3 ? 25 : 40

    Component.onCompleted: {
        Cpp_PLC.read_Bracket_Parameters_Parameter_Setting_Hold();
    }

    A_NumberKeyboard{
        id: bracketParameterKeyboard
        isDirectOverwrite: false
    }

    Row{
        anchors.horizontalCenter: bracketParameterBack_ParameterWindow.horizontalCenter
        anchors.top: bracketParameterBack_ParameterWindow.top
        anchors.topMargin: 30

        spacing: 30

        Item{
            width: 550
            height: 80

            Rectangle{
                width: 50
                height: 50
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 5
                color: Cpp_PLC.M_243 ? "red" : "white"
                border.width: 1
                radius: 25
            }

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 100
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("前托料架")
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.Y15 ?qsTr("开 启") : qsTr("关 闭")
                isSelected: Cpp_PLC.Y15

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(115,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(115,false)
            }

        }
        Item{
            width: 550
            height: 80

            Rectangle{
                width: 50
                height: 50
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 5
                color: Cpp_PLC.M_244 ? "red" : "white"
                border.width: 1
                radius: 25
            }

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 100
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("中托料架")
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.Y16 ?qsTr("开 启") : qsTr("关 闭")
                isSelected: Cpp_PLC.Y16

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(116,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(116,false)
            }

        }
        Item{
            width: 550
            height: 80

            Rectangle{
                width: 50
                height: 50
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 5
                color: Cpp_PLC.M_245 ? "red" : "white"
                border.width: 1
                radius: 25
            }

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 100
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("后托料架")
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.Y17 ?qsTr("开 启") : qsTr("关 闭")
                isSelected: Cpp_PLC.Y17

                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(117,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(117,false)
            }
        }


    }


    Column{
        anchors.horizontalCenter: bracketParameterBack_ParameterWindow.horizontalCenter
        anchors.top: bracketParameterBack_ParameterWindow.top
        anchors.topMargin: 120

        spacing: 5

        Item{
            width: 1500
            height: 170

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 10
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("前托触发点")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 290
                inputWidth: 300
                inputHeight: 80
                keyboard: bracketParameterKeyboard
                text: Cpp_PLC.Bracket_Front_Location

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(1294,value)
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 240
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_512 ? qsTr("小 于") : qsTr("大 于")
                isSelected: Cpp_PLC.M_512

                onButtonClicked: {
                    if(!Cpp_PLC.M_512)
                    {
                        Cpp_PLC.write_into_PLC_Coils(512,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(512,false)
                    }
                }
            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_515 ? qsTr("有 效") : qsTr("无 效")
                isSelected: Cpp_PLC.M_515

                onButtonClicked: {
                    if(!Cpp_PLC.M_515)
                    {
                        Cpp_PLC.write_into_PLC_Coils(515,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(515,false)
                    }
                }

            }

        }
        Item{
            width: 1500
            height: 170

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 10
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("中托触发点")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 290
                inputWidth: 300
                inputHeight: 80
                keyboard: bracketParameterKeyboard
                text: Cpp_PLC.Bracket_Mid_Min

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(296,value)
                }


            }

            Rectangle{
                width: 300
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 595
                color: "transparent"

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("≤   落下区间  ≤")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 900
                inputWidth: 300
                inputHeight: 80
                keyboard: bracketParameterKeyboard
                text: Cpp_PLC.Bracket_Mid_Max

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(1296,value)
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_516 ? qsTr("有 效") : qsTr("无 效")
                isSelected: Cpp_PLC.M_516

                onButtonClicked: {
                    if(!Cpp_PLC.M_516)
                    {
                        Cpp_PLC.write_into_PLC_Coils(516,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(516,false)
                    }
                }
            }

        }
        Item{
            width: 1500
            height: 170

            Rectangle{
                width: 200
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 10
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("后托触发点")
                }

            }

            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 290
                inputWidth: 300
                inputHeight: 80
                keyboard: bracketParameterKeyboard
                text: Cpp_PLC.Bracket_Back_Location

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(1298,value)
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 240
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_514 ? qsTr("小 于") : qsTr("大 于")
                isSelected: Cpp_PLC.M_514

                onButtonClicked: {
                    if(!Cpp_PLC.M_514)
                    {
                        Cpp_PLC.write_into_PLC_Coils(514,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(514,false)
                    }
                }
            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 20
                buttonWidth: 200
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_517 ? qsTr("有 效") : qsTr("无 效")
                isSelected: Cpp_PLC.M_517

                onButtonClicked: {
                    if(!Cpp_PLC.M_517)
                    {
                        Cpp_PLC.write_into_PLC_Coils(517,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(517,false)
                    }
                }
            }
        }
        Item{
            width: 1500
            height: 170

            Rectangle{
                width: 400
                height: 80
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 10
                color: "transparent"
                // border.width: 1

                Text{
                    anchors.centerIn: parent
                    font.pixelSize: fontSize
                    font.bold: true
                    text: qsTr("托料架安全距离")
                }

            }



            A_NumberInput{
                anchors.verticalCenter: parent.verticalCenter
                anchors.left: parent.left
                anchors.leftMargin: 490
                inputWidth: 300
                inputHeight: 80
                keyboard: bracketParameterKeyboard
                text: Cpp_PLC.Bracket_Safe_Distance

                onEditingFinished: function(value){
                    Cpp_PLC.write_into_PLC_32_Hold(612,value)
                }

            }

            A_Button{
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 200
                buttonWidth: 300
                buttonHeight: 80
                contentText_Data: Cpp_PLC.M_499 ? qsTr("检测托料架") : qsTr("不检测托料架")
                isSelected: Cpp_PLC.M_499

                onButtonClicked: {
                    if(!Cpp_PLC.M_499)
                    {
                        Cpp_PLC.write_into_PLC_Coils(499,true)
                    }
                    else
                    {
                        Cpp_PLC.write_into_PLC_Coils(499,false)
                    }
                }
            }


        }

    }


    Rectangle{
        width: 1200
        height: 1
        color: "black"
        anchors.horizontalCenter: bracketParameterBack_ParameterWindow.horizontalCenter
        anchors.bottom: bracketParameterBack_ParameterWindow.bottom
        anchors.bottomMargin: 100
    }

    Rectangle{      // 普通加工 - 手动操作按钮
        anchors.horizontalCenter: bracketParameterBack_ParameterWindow.horizontalCenter
        anchors.bottom: bracketParameterBack_ParameterWindow.bottom
        anchors.bottomMargin: 10
        width: 1750
        height: 80
        color: "transparent"

        Row{
            anchors.centerIn: parent
            spacing: 50

            A_Button{
                buttonWidth: 300
                buttonHeight: 80
                contentText_Data: qsTr("左 移")
                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(21,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(21,false)
            }
            A_Button{
                buttonWidth: 300
                buttonHeight: 80
                contentText_Data: qsTr("右 移")
                onButtonPressed: Cpp_PLC.write_into_PLC_Coils(22,true)
                onButtonReleased: Cpp_PLC.write_into_PLC_Coils(22,false)
            }

        }

    }

}
